import { R_tableData, R_add, R_update, R_remove } from "@/utils/tableData";


import request from '@/utils/request'

export const A_tableData = function(data) {
    return R_tableData({
        method: 'post',
        url: '/project/hList',
        data,
    })
}

export const A_findTableData = function(data) {
    return R_tableData({
        method: 'post',
        url: '/project/getHProject',
        data
    })
}

export const A_add = function(data) {
    return R_add({
        method: 'post',
        url: '/project/hAdd',
        data
    })
}


export const A_update = function(data) {
    return R_update({
        method: 'post',
        url: '/project/hUpdate',
        data
    })
}

/**
 * 
 * @param {*} ID key
 * @returns 
 */
export const A_remove = function(ID) {
    return R_remove({
        method: 'post',
        url: '/project/hDelete',
        data: {
            hkey: ID
        }
    })
}


export const A_check_T = async function(data) {
    let result = await request({
        method: 'post',
        url: '/project/hCheck',
        data,
    })
    return result
}


export const A_check_F = async function(data) {
    let result = await request({
        method: 'post',
        url: '/project/hPassNot',
        data,
    })
    return result
}

/**
 * 下载表格
 * @param {*} data 
 * @returns 
 */
export const A_downLoadExcel = async function() {
    let res = await request({
        method: 'post',
        url: '/project/hDownloadExcel',
        headers: {
            "Content-Type": 'application/octet-stream;charset=UTF-8'
        },
        responseType: 'blob'
    })
    return res
}

/**
 * 获取个人附件
 * @param {*} hkey 唯一标识
 */
export const A_getFile = async function(hkey) {
    let res = await request({
        method: 'post',
        url: '/project/hPerfile',
        data: {
            hkey
        }
    })
    return res
}

// /**
//  * 获取一级等级
//  * @returns 
//  */
// export const A_getLevel1 = async function() {
//     let res = await request({
//         method: 'get',
//         url: '/project/listHCategory'
//     })
//     return res
// }

export const A_downLoadExample = async function() {
    let res = await request({
        method: 'get',
        url: '/project//downloadExcelExampleH',
        headers: {
            "Content-Type": 'application/octet-stream;charset=UTF-8'
        },
        responseType: 'blob'
    })
    return res
}